package com.jari.lg.service.profile.carstatistic;

import com.jari.lg.domain.FrequentCarEntity;
import com.jari.lg.mapper.FrequentCarEntityMapper;
import com.jari.lg.utils.Constants;
import com.jari.lg.utils.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class FrequentCarService {

    @Autowired
    private FrequentCarEntityMapper frequentCarEntityMapper;

    /*
     * 套牌车，每天造1000条记录
     * */
    @Scheduled(cron = "* */1 * * * ?")
    public void makeInfo(){
        FrequentCarEntity entity ;
        for(int i = 0 ; i < 1000 ; i++){
            entity  = generate();
            frequentCarEntityMapper.insert(entity);
        }

    }

    //
    private FrequentCarEntity generate(){
        FrequentCarEntity entity = new FrequentCarEntity();
        entity.setCreator("SYS");
        entity.setDatastatus(Constants.DATA_STATUS_ONE);
        //十小时以内的结束时间
        entity.setEnddatetime(Utils.makeAfterDate(Utils.makeRandInt(600)));
        entity.setPlatenumber(Utils.createPlateNumber());
        entity.setPlatetype(Utils.createPlateType());
        entity.setGmtcreate(new Date());
        entity.setStartdatetime(new Date());
        entity.setTimes(Utils.makeRandInt(10));
        return entity;
    }

}
